import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.junit.Before;
import org.junit.Test;


public class RoomTest {
	
	Person a;
	Person b;
	Person c;
	
	Person x;
	Person y;
	Person z;
	
	List<Person> originalRoom;
	List<Person> newRoom;

	@Before
	public void setUp() throws Exception {
		a = new Person("a", "a");
		b = new Person("b", "b");
		c = new Person("c", "c");
		
		x = new Person("x", "x");
		y = new Person("y", "y");
		z = new Person("z", "z");
		
		originalRoom = new ArrayList<Person>();
		originalRoom.add(a);
		originalRoom.add(b);
		originalRoom.add(c);
		
		newRoom = new ArrayList<Person>();
	}

	@Test
	public void bigTest() {
		
		// original room (first sample)
		
		Room<Person> myRoom = new Room<Person>();
		
		myRoom.changeRoomContents(originalRoom);
		
		// new room contents (second sample)
		
		Room<Person> nextRoomSample = new Room<Person>();
		
		newRoom.add(a);
		newRoom.add(b);
		newRoom.add(x);
		newRoom.add(y);
		
		nextRoomSample.changeRoomContents(newRoom);
		
		Set<Person> arrivals = myRoom.getArrivals(nextRoomSample);
		assertTrue(arrivals.size() == 2);
		
		assertTrue(arrivals.contains(x));
		assertTrue(arrivals.contains(y));
		
		Set<Person> departures = myRoom.getDepartures(nextRoomSample);
		
		assertTrue(departures.size() == 1);
		
		assertTrue(departures.contains(c));
		
		// Now that something has been done with arrivals/departures
		// replace old room contents with new room contents
		
		myRoom.changeRoomContents(newRoom);
		
		assertTrue(myRoom.size() == 4);
		
		assertTrue(myRoom.contains(a));
		assertTrue(myRoom.contains(b));
		assertTrue(myRoom.contains(x));
		assertTrue(myRoom.contains(y));		
	}

}
